class Queue {
    constructor() {
        this.stackA = new Array();
        this.stackB = new Array();
    }
    enQueue(element) {
        this.stackA.push(element);
    }
    deQueue(element) {
        if (this.stackB.length === 0) {
            if (this.stackA.length === 0) {
                return null;
            }
            this.transfer();
        }
        return this.stackB.pop();
    }
    transfer() {
        while (this.stackA.length > 0) {
            this.stackB.push(this.stackA.pop());
        }
    }
}

const queue = new Queue();
queue.enQueue(1);
queue.enQueue(2);
queue.enQueue(3);
console.log(queue.deQueue());
console.log(queue.deQueue());
queue.enQueue(4);
console.log(queue.deQueue());
console.log(queue.deQueue());